
package com.amigo.online.provider.manager.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.provider.manager.model.entity.AdvTanApplyTbl;
import com.amigo.online.provider.manager.model.entity.AdvTanSourceTbl;
import com.amigo.online.provider.manager.result.AdvTanInfo;
import com.amigo.online.provider.manager.service.AdvTanApplyTblService;
import com.amigo.online.provider.manager.service.AdvTanSourceTblService;

/**
 * <code>AdvTanController.java</code>
 * <p>
 * : 探探广告controller
 * </p>
 * <p>
 *
 * @author LuChen
 * @version 1.0
 * @company Amigo
 * @time 2018年11月29日 上午10:47:32
 * @lastUpdate 无
 * </p>
 */
@RestController
@RequestMapping(value = "/advTanApplyTbl", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AdvTanController extends BaseController {

    @Autowired
    private AdvTanApplyTblService advTanApplyTblService;

    @Autowired
    private AdvTanSourceTblService advTanSourceTblService;


    /**
     * 添加广告基本信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping(value = "/addTanAdv")
    public ResponseEntity<Response> addTanAdv(@RequestBody AdvTanApplyTbl advTanApplyTbl) {
        AdvTanApplyTbl re = advTanApplyTblService.addAdvTanApply(advTanApplyTbl);
        return success(re);
    }


    /**
     * 添加广告资源
     *
     * @param advNearbySourceTbl
     * @return
     */
    @PostMapping(value = "/addTanAdvSource")
    public ResponseEntity<Response> addTanAdvSource(@RequestBody AdvTanSourceTbl advTanSourceTbl) {
        AdvTanSourceTbl re = advTanSourceTblService.addAdvTanSourceApply(advTanSourceTbl);
        return success(re);
    }


    /**
     * 修改附近广告基本信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping(value = "/updateTanAdvInfo")
    public ResponseEntity<Response> updateTanAdvInfo(@RequestBody AdvTanApplyTbl advTanApplyTbl) {
        boolean re = advTanApplyTblService.updateAdvTanApply(advTanApplyTbl);
        return success(re);
    }


    /**
     * 修改广告资源
     *
     * @param advNearbySourceTbl
     * @return
     */
    @PostMapping(value = "/updateTanAdvSourceInfo")
    public ResponseEntity<Response> updateTanAdvSourceInfo(@RequestBody AdvTanSourceTbl advTanSourceTbl) {
        boolean re = advTanSourceTblService.updateAdvTanSource(advTanSourceTbl);
        return success(re);
    }


    /**
     * 根据不同条件查询附近的广告基本信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping("/getTanAdvInfo")
    public ResponseEntity<Response> getTanAdvInfo(@RequestBody AdvTanApplyTbl advTanApplyTbl) {
        JSONObject re = advTanApplyTblService.findTanAdv(advTanApplyTbl);
        return success(re);
    }

    /**
     * 根据id查询广告的详细信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @GetMapping("/getTanAdvDetailInfo")
    public ResponseEntity<Response> getTanAdvDetailInfo(Long id) {
        AdvTanInfo info = advTanApplyTblService.findTanAdvDetailInfo(id);
        return success(info);
    }


    /**
     * 根据id删除附近广告信息
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @DeleteMapping("/deleteTanAdv")
    public ResponseEntity<Response> deleteTanAdv(@RequestBody AdvTanApplyTbl advTanApplyTbl) {
        boolean re = advTanApplyTblService.deleteById(advTanApplyTbl);
        return success(re);
    }


    /**
     * 审核附近广告
     *
     * @param advNearbyApplyTbl
     * @return
     */
    @PostMapping("/check")
    public ResponseEntity<Response> checkTanAdv(@RequestBody AdvTanApplyTbl advTanApplyTbl) {
        boolean re = advTanApplyTblService.checkAdv(advTanApplyTbl);
        return success(re);
    }


}

